<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" type="text/css" href="../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../css/list.css">
</head>
<style>
    .gouyao {
        padding: 0 0.5rem;
        background-color: #fff;
    }

    .gouyao .gouyao_btn {
        width: 100%;
        background-color: #2780e8;
        font-size: 0.7rem;
        color: #fff;
        height: 2.2rem;
        line-height: 2.2rem;
        text-align: center;
        border-radius: 0.2rem;
    }

    .gouyao .gouyao_btn p:last-child {
        color: #FFCECB;
        font-size: 0.7rem;
    }

    .chufang {
        padding: 0.8rem;
        background-color: #fff;
    }

    .chufang .chufang_title {
        color: #303030;
        font-size: 0.7rem;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid #e8e8e8;
    }

    .chufang .chufang_title span {
        color: #2780e8;
        float: right;
    }

    .yaodian {
        width: 100%;
        height: 2rem;
        padding: 0.8rem 0;
    }

    .yaodian img {
        width: 2rem;
        height: 100%;
    }

    .yaodian .yaodian_info {
        float: right;
        width: 14.5rem;
        height: 100%;
    }

    .yaodian .store-info {
        font-size: 0.6rem;
        text-indent: 0.4rem;
        height: 1.38rem;
        padding: 0.2rem;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-box-orient: vertical;
        -webkit-line-clamp: 2;
    }

    .yaodian .yaodian_name {
        color: #303030;
        font-size: 0.7rem;
    }

    .yaodian .yaodian_other {
        margin-top: 0.2rem;
        color: #838383;
        font-size: 0.5rem;
    }



    .chufang .yaocai {
        width: 100%;
        background-color: #FFF4F3;
        border-top: 1px solid #e7e7e5;
    }

    .chufang .yaocai .yaocai_item {
        width: 33.3%;
        height: 2.5rem;
        line-height: 2.5rem;
        text-align: center;
        color: #565656;
        font-size: 0.7rem;
    }

    .aui-list-item .yizhu {
        font-size: 0.7rem;
        height: auto;
        width: 100%;
    }

    .aui-list-item .yizhu .title {
        display: block;
        border-bottom: 1px solid #e8e8e8;
        height: auto;
        width: 100%;
        font-size: 0.7rem;
    }

    .aui-list-item .yizhu .input-yizhu {
        clear: both;
        display: block;
        padding: 0.8rem 0;
        font-size: 0.7rem;
        height: auto;
        margin-bottom: 0.8rem;
    }

    .aui-list-item .yizhu .input-yizhu textarea {
        display: inline-block;
        font-size: 0.7rem;
        color: #565656;
        height: 5.4rem;
    }

    /*.now_buy {
        margin-top: 1rem;
        width: 100%;
        height: 2.5rem;
        text-align: center;
        line-height: 2.5rem;
        color: #fff;
        background-color: #2780e8;
        font-size: 0.8rem;
    }*/

    .img_div {
        width: 100%;
        margin-bottom: 0.3rem;
        text-align: left;
    }

    .img_div img {
        width: 95%;
        margin: 0 0.4rem;
        background-color: #ccc;
        vertical-align: middle;
    }

    .cover {
        position: fixed;
        width: 100%;
        height: 100%;
        background-color: rgba(0, 0, 0, 0.7);
        left: 0;
        top: 0;
        z-index: 99;
        display: none;

    }

    .clear {
        clear: both;
        height: 0;
        margin: 0;
        padding: 0;
    }

    .aui-list-item .using {
        border-bottom: 1px solid #ededed;
        font-size: 0.7rem;
    }

    .aui-list-item .using span {
        display: inline-block;
        width:
    }

    .aui-list-item .aui-list-item-right .useing_arrow {
        width: 0.4rem;
        display: inline-block;
    }

    .aui-list-item .aui-list-item-right .useing_arrow img {
        width: 0.4rem;
    }


    .aui-list-item .useing_method span:nth-child(3) {
        margin-right: 0.5rem;
        float: right;
    }

    .aui-list-item .useing_detail {
        font-size: 0.7rem;
        color: #565656;
    }

    .aui-list-item .useing_detail input {
        width: 15%;
        text-align: center;
        color: #2780e8;
        font-weight: bold;
    }

    .aui-list-item .fanganshezhi_item {
        height: 2.1rem;
        border-bottom: 1px solid #f5f5f5;
        line-height: 2rem;
        color: #565656;
        font-size: 0.7rem;
    }

    .aui-list-item .aui-list-item-right .fanganshezhi_arrow {
        display: inline-block;
        width: 0.4rem;
    }

    .aui-list-item .aui-list-item-right .fanganshezhi_arrow img {
        width: 0.4rem;
    }

    .aui-list-item .aui-list-item-right .price {
        display: inline-block;
        font-size: 0.7rem;
    }

    .fanganshezhi {
        padding: 0 1rem;
        background-color: #fff;
        margin-bottom: 0.5rem;
    }

    .fanganshezhi .title {
        font-size: 0.8rem;
    }

    .fanganshezhi .fanganshezhi_item {
        height: 2.1rem;
        border-bottom: 1px solid #f5f5f5;
        line-height: 2rem;
        color: #565656;
        font-size: 0.7rem;
        position: relative;
    }

    .fanganshezhi .fanganshezhi_item .fanganshezhi_arrow {
        position: absolute;
        right: 0;
        width: 0.4rem;
        height: 0.7rem;
        top: 0.85rem;
    }

    .fanganshezhi .fanganshezhi_item .price {
        position: absolute;
        right: 1rem;
        top: 0.25rem;
    }

    .fanganshezhi .fanganshezhi_item .zhenjin {
        position: absolute;
        left: 0;
        top: 0.25rem;
    }


    .total {
        padding: 0 1rem 1rem 1rem;
        background-color: #fff;
        margin-bottom: 0.5rem;
    }

    .total .item {
        font-size: 0.7rem;
        color: #565656;
        line-height: 1.5rem;
    }

    .total .item span {
        color: #838383;
        float: right;
    }

    .total p {
        color: #565656;
        font-size: 0.5rem;
        margin-top: 0.5rem;
    }

    .total p:first-child {
        font-size: 0.8rem;
    }

    .order_btn {
        width: 90%;
        margin: 2rem 5%;
        height: 2.2rem;
        background-color: #2E8EFF;
        color: #fff;
        font-size: 0.8rem;
        text-align: center;
        border-radius: 0.5rem;
        line-height: 2.2rem;
    }

    .price_zhezhao_main {
        position: fixed;
        width: 16.25rem;
        margin-left: 1.25rem;
        bottom: 7.5rem;
        background-color: #fff;
        display: none;
        z-index: 999;
    }

    .price_zhezhao_main .price_title {
        padding: 1rem 0 1rem 1rem;
        color: #565656;
        font-size: 0.8rem;
    }

    .price_zhezhao_main .price_div {
        padding: 0 1rem;
        overflow-y: auto;
        height: 11rem;
    }

    .price_zhezhao_main .price_div .price_div_item {
        line-height: 2rem;
        color: #565656;
        font-size: 0.7rem;
    }

    .price_zhezhao_main .price_div input {
        line-height: 2rem;
        color: #565656;
        font-size: 0.7rem;
        outline: none;
        border-bottom: none;
    }

    .price_zhezhao_main .btn_div {
        width: 100%;
        height: 3rem;
        line-height: 3rem;
    }

    .price_zhezhao_main .btn_div span {
        width: 49%;
        display: inline-block;
        /* margin-left: -0.25rem; */
        text-align: center;
        color: #565656;
        font-size: 0.7rem;
    }

    .order_success_main {
        width: 14rem;
        height: 17.75rem;
        background: url('../image/award_img.png');
        background-size: 100% 100%;
        margin: 7.5rem 0 0 2.5rem;
        text-align: center;
    }

    .order_success_main .order_success_main_title {
        color: #FDDBAF;
        font-size: 1.2rem;
        padding-top: 3rem;

    }

    .order_success_main .order_success_main_subtitle {
        color: #FDDBAF;
        font-size: 0.6rem;
        margin-top: 2rem;
        line-height: 0.75rem;
    }

    .order_success_main .order_success_main_tips {
        color: #FDDBAF;
        font-size: 0.6rem;
        margin-top: 2rem;
    }

    .order_success_main .close_btn {
        font-size: 0.7rem;
        margin: 4rem 0 0 2.9rem;
        text-align: center;
        color: #2780e8;
        background-color: #fff;
        width: 8.2rem;
        height: 2rem;
        line-height: 2rem;
        border-radius: 0.5rem;
    }
</style>

<body>
    <div  id="app" v-cloak>
        <div class="placeholder_div"></div>

        <div class="gouyao">
            <div class="gouyao_btn">
                <p v-if="status == 1">未生成方案</p>
                <p v-if="status == 2">已生成方案</p>
            </div>
        </div>
        <div class="aui-content aui-margin-b-15">
            <ul class="aui-list aui-list-in">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">患者姓名</div>
                        <div class="aui-list-item-right">
                            <input type="text" placeholder="请输入患者姓名" v-model="patient_name" style="text-align:right;">
                        </div>
                    </div>
                    <div style="clear"></div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">性别</div>
                        <div class="aui-list-item-right">
                            <input type="text" v-model="sex_on" placeholder="请选择性别" readonly onclick="select_sex()"
                                style="text-align:right;">
                        </div>
                    </div>
                    <div style="clear"></div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">年龄</div>
                        <div class="aui-list-item-right"><input type="Number" v-model="patient_age"
                                style="text-align:right;"></div>
                    </div>
                    <div style="clear"></div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">拍方时间</div>
                        <div class="aui-list-item-right">{{info.createTime}}</div>
                    </div>
                    <div style="clear"></div>
                </li>
            </ul>
        </div>

        <div class="img_div" v-if="imgs">
            <img :src="imgs" alt="处方">
        </div>
        <div class="aui-content aui-margin-b-15">
            <ul class="aui-list aui-list-in">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">病名</div>
                        <div class="aui-list-item-right">
                            <input type="text" placeholder="请按照处方图中病名填写" v-model="bingming" style="text-align:right;">
                        </div>
                    </div>
                    <div style="clear"></div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">病症</div>
                        <div class="aui-list-item-right">
                            <input type="text" placeholder="请按照处方图中病症填写" v-model="bingzheng" style="text-align:right;">
                        </div>
                    </div>
                    <div style="clear"></div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">年龄(岁)</div>
                        <div class="aui-list-item-right">
                            <input type="Number" placeholder="岁" v-model="patient_age" style="text-align:right;">
                        </div>
                    </div>
                    <div style="clear"></div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">拍方时间</div>
                        <div class="aui-list-item-right">{{info.createTime}}</div>
                    </div>
                    <div style="clear"></div>
                </li>
            </ul>
        </div>
        <div class="placeholder_div"></div>
        <!-- 处方 -->
        <div class="chufang">
            <p class="chufang_title">
                药房
            </p>
            <div class="yaodian">
                <img :src="storeLogo" alt="">
                <div class="yaodian_info">
                    <p class="yaodian_name">{{info.store}}</p>
                    <p class="store-info">{{storeInfo}}</p>
                </div>
            </div>
            <div style="clear"></div>
            <p class="chufang_title">
                药材
            </p>
            <div class="yaocai" v-if="info.visible == 1">
                <span class="yaocai_item" v-for="item in info.drugsList">
                    {{item.drugs_name}} {{item.quantity}}g
                </span>
            </div>
        </div>
        <div class="aui-margin-b-15">
            <ul class="aui-list aui-list-in">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">当药前处方是否可见</div>
                        <div class="aui-list-item-right" v-if="info.visible == 1">可见</div>
                        <div class="aui-list-item-right" v-else>不可见</div>
                    </div>
                    <div style="clear"></div>
                </li>

                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">诊金</div>
                        <div class="aui-list-item-right">￥{{info.billingMoney}}</div>
                    </div>
                    <div style="clear"></div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">药价</div>
                        <div class="aui-list-item-right">￥{{drugsPrice}}</div>
                    </div>
                    <div style="clear"></div>
                </li>
            </ul>
        </div>
        <div class="fanganshezhi">
            <div class="fanganshezhi_item" @click="changeCoverCss('service_price','block')">
                <span class="zhenjin">治疗服务费</span>
                <span class="price" v-if="serviceMoney == 0">免费</span>
                <span class="price" v-else>￥{{serviceMoney}}元</span>
                <img class="fanganshezhi_arrow" src="../image/arrow_right.png" alt="">
            </div>
        </div>

        <div class="aui-content aui-margin-b-15">
            <ul class="aui-list aui-list-in">
                <li class="aui-list-item">
                    <div class="aui-list-item-inner" onclick="select_useing_method()">
                        <div class="aui-list-item-title">用药方法</div>
                        <div class="aui-list-item-right">
                            <span class="method">{{useing_method_on}}</span>
                            <span class="useing_arrow"><img src="../image/arrow_right.png" alt=""></span>
                        </div>
                    </div>
                    <div style="clear"></div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">共</div>
                        <div class="aui-list-item-right totaltie" style="width:1.8rem;font-size:0.7rem"><input
                                type="Number" v-model="info.quantity" readonly="true" style="width:1rem;">帖</div>
                    </div>
                    <div style="clear"></div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">每日</div>
                        <div class="aui-list-item-right meiritieshu" style="width:1.8rem;font-size:0.7rem"><input
                                type="Number" v-model="meiri_tieshu" style="width:1rem;">帖</div>
                    </div>
                    <div style="clear"></div>
                </li>
                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-title">一帖分</div>
                        <div class="aui-list-item-right cifuyong" style="width:3.2rem;font-size:0.7rem"><input
                                type="Number" v-model="cishu" style="width:1rem;">次服用</div>
                    </div>
                    <div style="clear"></div>
                </li>

                <li class="aui-list-item">
                    <div class="aui-list-item-inner">
                        <div class="aui-list-item-label">
                            医嘱
                        </div>
                        <div class="aui-list-item-input">
                            <input type="text" readonly class="openwin" style="text-align:right;" data-win="yizhu_win"
                                v-model="yizhu_content" :data-content="yizhu_content" placeholder="请填写相关医嘱">
                        </div>
                    </div>
                </li>
            </ul>
        </div>
        <div class="placeholder_div"></div>

        <!-- 总计 -->
        <div class="total">
            <p class="title" v-if="totalMoney">总计<span>￥{{totalMoney}}</span></p>
            <div class="item">诊金 <span>￥{{info.billingMoney}}</span></div>
            <div class="item">治疗服务费 <span>￥{{serviceMoney}}</span></div>
            <div class="item">总药价 <span>{{drugsPrice}} x {{usage_num}} = ￥{{totalDrugsMoney}}</span></div>
            <p>*患者不展示治疗服务费，治疗服务费直接计入在药费总额中</p>
            <p>*不含运费、代煎费，药费依据购药时实际选择的药房而定</p>
        </div>

        <div class="order_btn" @click="queren">确认并发送方案</div>

        <!-- 遮罩层-->
        <div class="cover" :style="{display:coverCss.service_price}"></div>
        <div class="price_zhezhao_main" :style="{display:coverCss.service_price}">
            <p class="price_title">治疗服务费价格</p>
            <div class="price_div">
                <p class="price_div_item" @click="select_fuwu_price(0)">免费</p>
                <p class="price_div_item" v-for="(item,index) in serviceMoneyArray"
                    @click="select_fuwu_price(item.servicePrice)">
                    <span v-if="item.servicePrice == 0">免费</span>
                    <span v-else>{{item.title}}</span>
                </p>
            </div>
            <div class="btn_div"></div>
        </div>
        <!-- 遮罩层-->
        <!-- 成功开单的遮罩 -->
        <div class="cover" :style="{display:coverCss.order_success}">
            <div class="order_success_main">
                <p class="order_success_main_title">开出方案成功!</p>
                <p class="order_success_main_subtitle">恭喜您成功开出方案 </p>
                <!-- <p class="order_success_main_tips">奖励请在【我的收入】中查看</p> -->
                <div class="close_btn" @click="changeCoverCss('order_success','none')">知道了</div>
            </div>
        </div>
    </div>

</body>

</html>
<script src="../script/set_root.js"></script>

<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hb.js"></script>
<script type="text/javascript" src="../script/vue.js"></script>
<script type="text/javascript">
    apiready = function () {
        hb_ready();
        get_zhenjin() // 服务费数据
        app.status = api.pageParam.status;
        get_ajax("prescribe/plan-photo/view", {
            id: api.pageParam.id
        }, function (res, err) {//alert(JSON.stringify(res))
            if (res.code == 200) {
                app.info = res.data
                app.usage_num = res.data.quantity ? res.data.quantity : 1

                if (res.data.prescription) {
                    app.imgs = IMAGE_HTTP + res.data.prescription
                }
                //计算药材费用
                var drugsList = res.data.drugsList;
                for (key in drugsList) {
                    var item = drugsList[key].drugs_name + drugsList[key].quantity + "g"
                    app.prescription.push(item)
                    var drugsLists = {
                        userId: app.info.userId,
                        name: drugsList[key].drugs_name,
                        drugsNo: drugsList[key].drugs_no,
                        specs: drugsList[key].specs,
                        unit: "g",
                        quantity: drugsList[key].quantity,
                        salePrice: drugsList[key].sale_price,
                        remark: "无备注"
                    }
                    app.prescribeDrugs.push(drugsLists);
                    app.drugsPrice += (Number(drugsList[key].sale_price) * Number(drugsList[key].quantity));
                }
                app.totalDrugsMoney = $api.toThreeDecimal(Number(app.drugsPrice) * Number(res.data.quantity))

                moren_jine();
                app.totalMoney = Number(app.info.billingMoney) + Number(app.serviceMoney) + Number(app.totalDrugsMoney)
                app.totalMoney = $api.toThreeDecimal(app.totalMoney)
                get_ajax("store/view", {
                    id: res.data.storeId
                }, function (ret, err) {
                    if (ret.code == 200) {
                        app.storeLogo = IMAGE_HTTP + ret.data.logo
                        app.storeInfo = ret.data.introduce
                    }
                });

                get_ajax("user/view", {
                    userId: res.data.userId
                }, function (res, err) {
                    if (res.code == 200) {
                        if (res.data) {
                            app.patient_name = res.data.realname ? res.data.realname : "匿名";
                            app.patient_age = res.data.age ? res.data.age : "1";
                            app.sex = res.data.sex ? res.data.sex : 1;
                        }
                    }

                });

            }
        });

        // 接收医嘱页面传出来的医嘱
        api.addEventListener({
            name: 'chuandi_yizhu'
        }, function (ret, err) {
            app.yizhu_content = ret.value.content

            app.$nextTick(function () {
                hb_init_openwinby_click();
            })
        });
    }
    //使用vue对数据进行绑定
    var app = new Vue({
        el: '#app',
        data: {
            info: "",
            status: 0,
            storeLogo: "",
            storeInfo: "",
            coverCss: {
                service_price: "none",
                order_success: "none",
            },
            imgs: "",
            yizhu_content: "", //医嘱内容
            sex: 1,
            sex_on: "男",
            sex_btns: ["男", "女"],
            patient_name: "", // 患者姓名
            patient_age: 1, // 患者年龄
            bingming: "", // 病名
            bingzheng: "", // 病症
            useing_method_on: "内服", // 用药方法
            useing_method_btns: ["内服", "外用"],
            useing_method: 1, // 用药方法 1=内服 2=外用
            usage_detail: "", // 用法详述，在created方法中定义
            usage_num: 1, // 用量数，默认1
            meiri_tieshu: 1, // 每日多少帖
            cishu: 2, // 一帖多少次
            serviceMoneyArray: [], // 服务费数组
            serviceMoney: "0", // 服务费
            totalMoney: 0.000, // 合计金额
            totalDrugsMoney: 0.000,//所有付数用量总药价
            drugsPrice: 0.000, // 单贴全部药价
            prescription: [],//药材字符串
            prescribeDrugs: []
        },
        methods: {
            // 遮罩层中选择服务费
            select_fuwu_price: function (price) {
                // alert(price)
                this.serviceMoney = price
                this.coverCss.service_price = "none"

                app.$nextTick(function () {
                    hb_init_openwinby_click();
                })
            },
            // 确认新增开方
            queren: function () {
                if (!this.patient_name) {
                    toast("请输入患者姓名")
                    return;
                }
                if (!this.patient_age) {
                    toast("请输入患者年龄")
                    return;
                }
                if (!this.bingming) {
                    toast("请输入病名")
                    return;
                }
                if (!this.bingzheng) {
                    toast("请输入病症")
                    return;
                }

                if (!this.usage_num) {
                    toast("请输入用量数")
                    return;
                }

                if (!this.meiri_tieshu) {
                    toast("请输入每日使用多少帖")
                    return;
                }
                if (!this.cishu) {
                    toast("请输入每一帖使用多少次数")
                    return;
                }
                if (!this.yizhu_content) {
                    toast("请输入相关医嘱")
                    return;
                }

                post_ajax("prescribe/plan/save", {
                    doctorId: String($api.getStorage("emp").userId), // 医生账号id
                    doctor: $api.getStorage("emp").realname ? $api.getStorage("emp").realname : "匿名", // 医生姓名
                    userId: String(app.info.userId), // 选择的患者id
                    name: String(app.patient_name), // 患者姓名
                    sex: String(app.sex), // 患者性别
                    age: String(app.patient_age), // 患者年龄
                    diseases: String(app.bingming), // 病名
                    dialectical: String(app.bingzheng), // 病症
                    storeId: String(app.info.storeId), // 药房id
                    store: String(app.info.store), // 药房名称
                    source: "photo",
                    storeLogo: String(this.storeLogo), // 药房logo
                    dosageFormId: String(this.info.storeServiceTypeId), // 剂型id
                    dosageForm: String(this.info.storeServiceType) ? String(this.info.storeServiceType) : "中药饮片",
                    prescription: String(app.prescription), // 处方药材
                    usages: String(app.useing_method), //用药方法
                    quantity: String(app.usage_num), // 总量多少帖
                    usageNum: String(app.meiri_tieshu), // 每日多少帖
                    times: String(app.cishu), // 一贴分多少次服用
                    usageDetail: String(app.usage_detail), // 用法详述
                    medicalAdvice: String(app.yizhu_content), //医嘱
                    visible: String(this.info.visible), // 购药前处方是否可见
                    billingMoney: String(this.info.billingMoney), // 诊费诊金
                    serviceMoney: String(app.serviceMoney), // 服务费
                    drugMoney: String($api.toThreeDecimal(app.drugsPrice)), // 单贴药价
                    totalMoney: String(app.totalMoney), // 合计金额
                    remark: '无备注', // 备注
                    prescribeDrugs: app.prescribeDrugs, // 处方药材
                }, function (res, err) {
                    //alert(JSON.stringify(res))
                    if (res.code == "200") {
                        get_ajax("prescribe/plan/im-message", {
                            id: res.data
                        }, function (result, error) {
                            if (result.code == 200) {
                                send_msg(JSON.stringify(result.data))
                            }
                        })
                        app.coverCss.order_success = "block";
                        // setTimeout(function () {
                        //     api.closeWin()
                        // }, 500);
                        app.$nextTick(function () {
                            hb_init_openwinby_click();
                        })
                    }
                })
            },
            changeCoverCss: function (val, css) {
                if (val == "service_price") {
                    app.coverCss.service_price = css;
                } else if (val == "order_success") {
                    app.coverCss.order_success = css;
                }
            },
        },
        watch: {
            coverCss: function (val) {
                if (val) {
                    $("body").css('overflow', 'hidden')
                } else {
                    $("body").css('overflow', 'visible');
                }

                app.$nextTick(function () {
                    hb_init_openwinby_click();
                })
            },

            serviceMoney: function (val) {
                this.totalMoney = Number(app.info.billingMoney) + Number(app.serviceMoney) + Number(app.totalDrugsMoney)
                this.totalMoney = $api.toThreeDecimal(this.totalMoney)
            },
            usage_num: function (val) {
                app.totalDrugsMoney = $api.toThreeDecimal(Number(app.drugsPrice) * Number(app.usage_num))
                moren_jine();
                app.totalMoney = Number(app.info.billingMoney) + Number(app.serviceMoney) + Number(app.totalDrugsMoney)
                app.totalMoney = $api.toThreeDecimal(app.totalMoney)
                this.usage_detail = "共" + val + "帖，每日" + this.meiri_tieshu + "帖，一贴分" + this.cishu + "次服用" // 定义用法详述
            },
            meiri_tieshu: function (val) {
                this.usage_detail = "共" + this.usage_num + "帖，每日" + val + "帖，一贴分" + this.cishu + "次服用" // 定义用法详述
            },
            cishu: function (val) {
                this.usage_detail = "共" + this.usage_num + "帖，每日" + this.meiri_tieshu + "帖，一贴分" + val + "次服用" // 定义用法详述
            }
        }
    });
    // 发送消息
    function send_msg(msg) {
        var identifier = $api.getStorage("emp").userId
        var side_identifier = app.info.userId
        var tencentIm = api.require('tencentIm');
        tencentIm.init({appid:"1400407726"}, function (ret, err) {
            if (ret) {
                // alert(JSON.stringify(ret));
                get_ajax("im/getUserSig", {
                    identifier: identifier
                }, function (res, err) {
                    tencentIm.login({
                        identifier: identifier,
                        userSig: res.data,
                    }, function (ret, err) {
                        if (ret) {
                            // alert(JSON.stringify(ret));

                            tencentIm.getConversation({
                                peer: side_identifier,
                                type: 1,
                            }, function (ret, err) {
                                if (ret) {
                                    tencentIm.sendText({
                                        peer: side_identifier,
                                        type: 1,
                                        text: msg,
                                    }, function (ret, err) {
                                        // if (ret) {
                                        //     // alert(JSON.stringify(ret));
                                        //     // alert(JSON.stringify(msg))
                                        //     alert("开方成功!")
                                        //     api.closeWin()
                                        // } else {
                                        //     // alert("网络不通畅，请稍后再试！");
                                        // }
                                    });
                                }
                            })

                        } else {
                            // alert("网络不通畅，请稍后再试！");
                        }
                    });
                })

            } else {
                // alert("网络不通畅，请稍后再试！");
            }
        });
    }

    function get_zhenjin() {
        get_ajax("doctor/service-price", {
            doctorUserId: $api.getStorage("emp").userId
        }, function (res, err) {
            if (res) {
                // alert(JSON.stringify(res))
                app.serviceMoneyArray = res.data
            }
        })
    }

    function moren_jine() {
        get_ajax("doctor/default-service-price", {
            doctorUserId: $api.getStorage("emp").userId,
            drugsPrice: String(app.totalDrugsMoney)
        }, function (res, err) {
            if (res.code == 200) {
                // alert(JSON.stringify(res))
                app.serviceMoney = res.data
            }
        })
    }
    // 选择性别
    function select_sex() {
        api.actionSheet({
            title: '请选择患者性别',
            cancelTitle: '取消',
            buttons: app.sex_btns
        }, function (ret, err) {
            var index = ret.buttonIndex; //下标从1开始
            if (index == 3) {
                return
            }
            app.sex = index;
            for (var i = 0; i < app.sex_btns.length; i++) {
                if (index - 1 == i) {
                    app.sex_on = app.sex_btns[i]
                }
            }
            app.$nextTick(function () {
                hb_init_openwinby_click();
            })
        });
    }

    // 选择用药方法
    function select_useing_method() {
        api.actionSheet({
            title: '选择用药方法',
            cancelTitle: '取消',
            buttons: app.useing_method_btns
        }, function (ret, err) {
            var index = ret.buttonIndex; //下标从1开始
            if (index == 3) {
                return
            }
            app.useing_method = index
            for (var i = 0; i < app.useing_method_btns.length; i++) {
                if (index - 1 == i) {
                    app.useing_method_on = app.useing_method_btns[i]
                }
            }
            app.$nextTick(function () {
                hb_init_openwinby_click();
            })
        });
    }

</script>
